package cn.merryyou.jpa.test;

import cn.merryyou.jpa.domain.primarykey.CourseUserPK;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Getter
@Setter
@Entity
@IdClass(CourseUserPK.class)
@NoArgsConstructor
public class CourseStudent {

    @Id
    @ManyToOne
    @JoinColumn(name = "course_id", unique = true)
    private Course course;
    @Id
    @ManyToOne
    @JoinColumn(name = "person_id", unique = true)
    private Person person;
    private Boolean accessable;//true redPackage is in user, otherwise not
    
    
    public CourseStudent(Course course, Person person, Boolean accessable) {
        this.course = course; 
        this.person = person;
        this.accessable = accessable; 
    }
}